<?php
namespace app\admin\validate\admin;

use app\common\model\AdminModel;
use app\common\validate\AdminBase;

class Admin extends AdminBase
{
	protected $rule =   [
	    'account' => 'require|checkAccount',
	];
	
	protected $message  =   [

	];
	
	protected $scene = [
	    'save' => ['account'],
	];

	// 自定义验证规则
	protected function checkAccount($value, $rule, $data=[])
	{
		$admin = AdminModel::getByAccount($data['account']);
		if ($admin) {
			if (empty($data['id']) || $data['id'] != $admin->id) {
				return '账号已存在';
			}
		}

		// 设置数据
		// request()->apppid = 1000111;

		return true;
	}
}

